package jsyf.oa.service.task;

import com.alibaba.fastjson.JSONObject;
import jsyf.oa.dao.task.YzmDao;
import jsyf.oa.entity.task.YzmEntity;
import jsyf.oa.facade.task.YzmFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;

/**
 * Created by y on 2018/6/5.
 */
@Service
@Transactional(rollbackFor = Exception.class)
@com.alibaba.dubbo.config.annotation.Service(protocol = {"dubbo"})
public class YzmService implements YzmFacade{
    @Autowired
    private YzmDao yzmDao;
    @Override
    public Boolean add(String userId, String yzm) {
        YzmEntity yzmEntity=new YzmEntity();
        yzmEntity.setUserId(userId);
        yzmEntity.setYzm(yzm);
        yzmEntity.setCreateTime(yzmDao.getCurrentTime());
        return yzmDao.add(yzmEntity)>0;
    }

    @Override
    public JSONObject findByUserIdAndYzm(String userId, String date) {
        return yzmDao.checkAndYzm(userId);
    }
}
